<template>
	<view>
		<!-- <button @click="addComponent">新增记账上报</button> -->
		<view v-for="(component, index) in components" :key="index">
			<view class="uni-list-cell" style="margin-top: 5%;">
				<view class="uni-list-cell-db">
					<text style="line-height: 100rpx;color: red;">选择上报类型:</text>
					<picker disabled
						style="line-height: 100rpx;color: #BEBEBE;font-size: 32rpx; padding-left: 250px;margin-top: -50px;padding-top: -100px;"
						@change="pick($event,index)" mode='selector' :value="components[index].index"
						:range="components[index].array" class='listPicker'>
						<view>{{ ww }}</view>
					</picker>
				</view>
			</view>
			<view>
				<view>金额：</view>
				<view>
					<input type="number" v-model="price" maxlength="20" placeholder="请输入金额" style="border: 1px solid rgba(0, 0, 0, 0.1);
					width: 200px;
					margin-top: -20px;
					margin-left: 50px;" @blur="idChange($event,index)" disabled />
				</view>
			</view>
			<view class="cell">
				<view class="cell-left">
					<view class="cell-text">照片上传：</view>
					<view class="cell-text" style="color: #8C8C8C;width: 180px;">(最多上传3张图片)</view>
				</view>
				<view class="cell-left">
					<view class="qtpicker">
						<!-- <view>MMMMM</view> -->
						<!-- 选中待上传的图片 -->
						<view class="preImgs" v-for="(val,index2) in preImgUrl" :key='index2'>
							<image style="border-radius: 6px;" mode="" :src="val" @click="showImg(val,index2)">
							</image>
						</view>

					</view>
				</view>
			</view>
		</view>
		<view style="margin-top: 20px;">
			<view>人员：</view>
			<view>
				<input type="text" maxlength="20" placeholder="请输入人员" v-model="personnel" style="border: 1px solid rgba(0, 0, 0, 0.1);
							width: 200px;
							margin-top: -20px;
							margin-left: 50px;" disabled />
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				personnel: '',
				price: '',
				ww: '',
				journalList: [],
				item: null,
				components: [],
				preImgUrl: [], //本地预览的图片数据
			};
		},

		onLoad(option) {
			this.item = JSON.parse(option.item)
			this.ww = this.item.content1
			this.price = this.item.money
			this.personnel = this.item.journalPerson
			let imgArr = []
			imgArr = this.item.piecturepath.split(',')
			let a = this.item.piecturepath.substring(0, this.item.piecturepath.length - 1);
			imgArr = a.split(',')
			this.preImgUrl = imgArr
		},
		methods: {
			onReady() {
				this.components.push({
					price: 0,
					imageData: '',
					selectedOption: '',
					array: ['出差车费', '出差采购', '出差住宿'],
					index: 0,
					images: [],
					preImgUrl: [], //本地预览的图片数据
					imgNum: 0, //一共选中了多少张照片,用来限制本次最大上传数量
					afterUploadPath: '', //上传图片后，返回上传后的图片地址入库用
					isShowAddImgBtn: true,
					content: '',
					fault_id: '',
					contentText: '',
					addoredit: 'add',
					editclick: 0, //是否点击了右上角的编辑按钮
					faultConfirmId: '',
					isShowDelImgBtn: true,
					submitForbide: false,
					radiobakcolor: '',
					completionStatus: null,
				});
			},

			//点击小图查看大图片
			showImg(val, index2) {
				// console.log(val, '点击了')
				let that = this
				uni.previewImage({
					// 对选中的图片进行预览
					urls: that.components[index].preImgUrl, //图片数组  // urls:['','']  图片的地址 是数组形式
					current: index, //当前图片的下标
				})
			},

		}
	}
</script>

<style scoped lang="scss">
	* {
		box-sizing: border-box;
	}

	.qtpicker {
		width: 100%;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		margin: 0 auto;
		padding: 10rpx 0;

		.preImgs {
			margin: 13rpx;
			position: relative;

			image {
				width: 200rpx;
				height: 200rpx;
			}

			.cuo {
				width: 17pt;
				height: 17pt;
				//line-height: 12px;
				//text-align: center;
				///* font-size: 16px; */
				//border-radius: 50%;
				//background-color: #223E4B;
				//color: #FFFFFF;
				position: absolute;
				right: 0px;
				top: 0px;
			}
		}


		.addImg {
			width: 200rpx;
			height: 200rpx;
			border: 2rpx solid #d4d4d4;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 20rpx;
			background-color: #e2dddd;
			margin-left: 13rpx;
			margin-top: 13rpx;
		}
	}

	.cell {
		height: auto;
		padding-left: 20rpx;
		padding-right: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;
		background: #fff;
		//border-bottom: 1px solid #BDD8F6;

		.cell-left {
			display: flex;
			align-items: center;
			padding: 8px;

			.cell-icon {
				width: 50rpx;
				height: 50rpx;
			}

			.cell-text {
				color: #595959;
				font-size: 15px;
				margin-left: 0rpx;

				//width: 180rpx;
			}
		}

		.iconfont {
			font-size: 40rpx;
			color: #999;
		}
	}

	.radio-content {
		height: 40rpx;
		display: flex;
		align-items: center;
	}

	.radio {
		width: 24rpx;
		height: 24rpx;
		border-radius: 50%;
		border: 1rpx solid #CCCCCC;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin: 0rpx 26rpx 0rpx 15rpx;
	}

	.radio-active {
		width: 10rpx;
		height: 10rpx;
		border-radius: 50%;
		background-color: #0079FC;
	}

	.radio-default {
		border: 2rpx solid #0079FC;
	}

	.radio-right {
		margin-left: 36rpx;
	}
</style>